class Stack:
    def __init__(self):
        "docstring"
        self.items = []

    def isEmpty(self):
        return self.items == []

    def push(self, item):
        self.items.append(item)

    def pop(self):
        return self.items.pop()

    def peek(self):
        return self.items[len(self.items) - 1]

    def size(self):
        return len(self.items)


def baseConverter(decNumber, base):
    digits = "0123456789ABCDEF"

    remstack = Stack()

    while decNumber > 0:
        rem = decNumber % base
        remstack.push(rem)
        decNumber = decNumber // base

    newString = ""
    while not remstack.isEmpty():
        newString = newString + digits[remstack.pop()]

    return newString


print(baseConverter(25, 2))
print(baseConverter(25, 16))


def decConverter(numberin, base):

    numberin = str(numberin)
    numstack = Stack()

    index = 0
    length = len(numberin)

    while index <= length:
        if numberin[index] in "ABCDEF":
            num = ord(numberin[index]) - 55
        else:
            num = int(numberin[index])
        num = num * (base ** (length - 1))
        numstack.push(num)
        index = index + 1
        length = length - 1

    decnum = 0
    while not numstack.isEmpty():
        decnum = decnum + numstack.pop()

    return decnum


print(decConverter(11, 8))
print(decConverter("A", 16))
